<?php
if(isset($this->request->params['named']['name'])) echo '<div style="display: none;">';
echo $this->ExtendedForm->input('name', array_merge(array('label' => __d('admin', 'Name'), 'class' => 'input-xxlarge')));
if(isset($this->request->params['named']['name'])) echo '</div>';

if(isset($this->request->params['named']['name_en'])) echo '<div style="display: none;">';
echo $this->ExtendedForm->input('name_en', array_merge(array('label' => __d('admin', 'Name En'), 'class' => 'input-xxlarge')));
if(isset($this->request->params['named']['name_en'])) echo '</div>';
?>
<p>
    Elements recipe 
    <button type="button" class="btn btn-success btn-xs" id="more-recipe-vn">Add Group</button>
</p>
<div class="control-group" id="elements-recipe-vn">
	<?php if(isset($elements)):?>
		<?php for($i = 0; $i < count($elements); $i++) :?>
		<div class="control-group">
			<?php if($i != 0):?>
			<hr>
			<button type="button" class="btn btn-danger btn-xs delete-detail" rel="">Delete Group</button><br><br>
			<?php endif;?>
			
			<div class="recipe-detail">
				<div class="form-group row">
					<div class="col-sm-6">
						<input class="form-control" type="text" maxlength="100" placeholder="element name" name="RecipeDetail[name][]" value="<?php echo $elements[$i]['RecipeDetail']['name']?>">
					</div>
					<div class="col-sm-6">
						<input class="form-control" type="text" maxlength="100" placeholder="element name en" name="RecipeDetail[name_en][]" value="<?php echo $elements[$i]['RecipeDetail']['name_en']?>">
					</div>
					<input type="hidden" name="RecipeDetail[recipe_detail_id][]" value="<?php echo $elements[$i]['RecipeDetail']['recipe_detail_id']?>">
				</div>
				<?php
				foreach($elements[$i]['RecipeStep'] as $step) :
					echo $this->element('AdminRecipes/edit_detail_vn', array('key'=>$i, 'step'=>$step));
				endforeach;
				?>
			</div>
			<div align="right"><i class="glyphicon glyphicon-plus-sign add-recipe1" rel="<?php echo $i?>" style="cursor:pointer"></i> Add element</div>
		</div>
		<?php endfor;?>
	<?php else: ?>
		<div class="recipe-detail">
			<div class="form-group row">
				<div class="col-sm-6">
					<input class="form-control" type="text" maxlength="100" placeholder="element name" name="RecipeDetail[name][]" value="">
				</div>
				<div class="col-sm-6">
					<input class="form-control" type="text" maxlength="100" placeholder="element name en" name="RecipeDetail[name_en][]" value="">
				</div>
			</div>
			<?php echo $this->element('AdminRecipes/detail_vn');?>
		</div>
		<div align="right"><i class="glyphicon glyphicon-plus-sign add-recipe" style="cursor:pointer"></i> Add element</div>
	<?php endif;?>
</div>